﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Demo;

namespace Ice.Demo.Server
{
    public class PrinterI : PrinterDisp_
    {
        public override void printString(string s, Current current__)
        {
            Console.WriteLine(s);
        }
    }

    public class Server
    {
        public static void Main(string[] args)
        {
            int status = 0;
            Ice.Communicator ic = null;
            try
            {
                ic = Ice.Util.initialize(ref args);
                Ice.ObjectAdapter adapter = ic.createObjectAdapterWithEndpoints("SimplePrinterAdapter", "default -p 10000");
                Ice.Object obj = new PrinterI();
                adapter.add(obj, ic.stringToIdentity("SimplePrinter"));
                adapter.activate();
                ic.waitForShutdown();
            }
            catch (Exception e)
            {
                Console.Error.Write(e);
                status = 1;
            }
            if (ic != null)
            {
                //Clean up
                try
                {
                    ic.destroy();
                }
                catch (Exception e)
                {
                    Console.Error.WriteLine(e);
                }
            }
            Environment.Exit(status);
        }
    }
}
